<script type="text/javascript">
        function getContentImages() {
                var content = $('.j-content').val();
                var image_sort = $("#imagesort").val();
                if (image_sort == '') {
                        image_sort = 1;
                }
                if (content != '') {
                        var imgReg = /&lt;img.*?(?:&gt;|\/&gt;)/gi;

                        var imgReg2 = /<img.*?(?:>|\/>)/gi;
                        //匹配src属性
                        var srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/gi;
                        var str_img = content.match(imgReg);
                        if (str_img == '' || str_img == null) {
                                str_img = content.match(imgReg2);
                        }
                        if (str_img == '' || str_img == null) {
                                return false;
                        }
                        if (str_img.length <= 0) {
                                return false;
                        }
                        if (image_sort > str_img.length) {
                                image_sort = 1;
                        }
                        $.each(str_img, function(n, value) {
                                if (n == (parseInt(image_sort) - 1)) {
                                        var reg2 = /src="([^"]+)"/;
                                        var result2 = reg2.exec(value);
                                        var image_path = RegExp.$1;
                                        $('#image_path').val(image_path);
                                }
                        });
                }
        }
</script>
<div class="bjui-pageContent" >
        <div data-layout-h="0">
                <!-- 内容区 -->
                <form action="{:U('News/news_add')}" name="newsaddform" class="pageForm nice-validator n-red"   data-loadingmask='false' data-toggle="validate" novalidate="novalidate" method="post" >
                        <input type="hidden" name="id" value="{$_GET.id|default=''}" />
                        <!-- navtab类型判断 -->
                        <input type="hidden" name="navTabname" value="News/news" />
                        <table  style="margin-top: 20px;">
                                <tr >
                                        <td><label style='margin-left:40px;'>新闻标题：</label></td>
                                        <td>
                                                <input type="text" name="subject" data-rule="required" size="40"  value="{$news.subject|default=''}" />
                                        </td>

                                </tr>
                                <tr>
                                        <td width='150'><label style='margin-left:40px;'>类别：</label></td>
                                        <td>
                                                <select data-toggle="selectpicker" data-rule='required' name="cid" >
                                                        <option value="">选择新闻分类</option>
                                                        {volist name="news_cat" id="vo"}
                                                        <option value="{$vo.id}" {eq name="news.cid" value="$vo['id']"} selected{/eq}>{$vo.title}</option>
                                                        {/volist}
                                                </select>   
                                        </td>

                                </tr>
                                <tr>
                                        <td width='150'><label style='margin-left:40px;'>新闻地区：</label></td>
                                        <td>
                                                <select name="country" id='w_combox_country' data-rule='required' data-toggle="selectpicker" data-nextselect="#w_combox_prov" data-refurl="{:U('Pub/get_zone_by_pid')}/id/{value}" data-emptytxt="--请选择--">
                                                        <option value="">--请选择--</option>
                                                        {volist name="top" id="vo"}
                                                        <option value="{$vo.id}" {eq name="news.country|default=''" value="$vo['id']"} selected{/eq}>{$vo.name}</option>
                                                        {/volist}

                                                </select>
                                                <select name="prov" id="w_combox_prov" data-rule='required' data-toggle="selectpicker"  data-nextselect="#w_combox_city" data-refurl="{:U('Pub/get_zone_by_pid')}/id/{value}" data-val="{$news.prov|default=''}" data-emptytxt="--请选择--">
                                                        <option value="">--请选择--</option>
                                                </select>
                                                <select name="city" id="w_combox_city" data-toggle="selectpicker" data-nextselect="#w_combox_scenic" data-refurl="{:U('Pub/get_zone_by_pid')}/id/{value}" data-val="{$news.city|default=''}"  data-emptytxt="--请选择--">
                                                        <option value="">--请选择--</option>
                                                </select>
                                                <select name="scenic" id="w_combox_scenic" data-toggle="selectpicker"  data-val="{$news.scenic|default=''}"  data-emptytxt="--请选择--">
                                                        <option value="">--请选择--</option>
                                                </select>

                                        </td>

                                </tr>

                                <tr >
                                        <td width='150' ><label style='margin-left:40px;'>内容：</label></td>
                                        <td>
                                                <div style="display: inline-block; margin-top:10px; vertical-align: middle;">
                                                        <textarea name="content" id="j_form_content" class="j-content" style="width: 700px;" data-toggle="kindeditor" data-rule='required' data-minheight="200">{$news.content|default=''}</textarea>
                                                </div>

                                        </td>

                                </tr>
                                <tr >
                                        <td><label style='margin-left:40px;'>缩略图：</label></td>
                                        <td>
                                                <input style="margin-top:10px;" name="image_sort" id="imagesort" type="text" size="10"  value="{$news.image_sort|default=1}" />(取编辑器内容的第几张图片就填几)
                                                <br /><br />
                                                {neq name="news.image_path|default=''" value=''}
                                                <img src='{$news.image_path}' width="100px" height="100px" />
                                                {/neq}
                                                <input name="image_path" type="hidden" id="image_path" value="{$news.image_path}" />
                                        </td>

                                </tr>
                                <tr >
                                        <td><label style='margin-left:40px;'>来源：</label></td>
                                        <td>
                                                <input type="text" name="comefrom"  size="40"  value="{$news.comefrom|default=''}" />
                                        </td>

                                </tr>
                                <tr >
                                        <td><label style='margin-left:40px;'>外部链接：</label></td>
                                        <td>
                                                <input type="text" name="link"  size="40"  value="{$news.link|default=''}" />
                                        </td>

                                </tr>
                                <tr >
                                        <td><label style='margin-left:40px;'>浏览次数：</label></td>
                                        <td>
                                                <input type="text" name="hits"  size="20"  value="{$news.hits|default=''}" />
                                        </td>

                                </tr>


                        </table>
                </form>
        </div>

</div>
<div class="bjui-pageFooter" border='none'>
        <ul>
                <li><button type="button" class="btn btn-close">关闭</button></li>
                <li><button type="submit" onclick="getContentImages();"  class="btn btn-default">提交</button></li>
        </ul>
</div>
